package puntaelena.facilitylocation.hillclimbing.solver.agents;

import java.util.ArrayList;
import java.util.List;


import puntaelena.facilitylocation.hillclimbing.solver.services.IFcltLocDataService;
import puntaelena.facilitylocation.hillclimbing.solver.services.IHillClimbingAgentRegistry;
import puntaelena.graphsupport.FacilitiesGraph;

import jfuzzyprincepless.agents.INegotiatingAgent;
import jfuzzyprincepless.algorithm.structure.IContext2forAgents;
import jfuzzyprincepless.negotiation.INegotiationContext;

public class IntroduceCitiesContext2forAgents
	implements IContext2forAgents
{
	@Override
	public List<INegotiatingAgent> getAgents(
		INegotiationContext icontext
	) {
		IFcltLocDataService flServ =
			icontext.getService(IFcltLocDataService.class);
		IHillClimbingAgentRegistry hcagReg =
			icontext.getService(IHillClimbingAgentRegistry.class);

		List<INegotiatingAgent> result =
			new ArrayList<INegotiatingAgent>();
		FacilitiesGraph fgraph = flServ.getFgraph();
		int citiesCount = fgraph.getCitiesCount();
		for (int i = 0; i < citiesCount; i++) {
			CityChoosesFacilityAgent cagent =
				new CityChoosesFacilityAgent(i);
			result.add(cagent);
			hcagReg.addCityAgent(cagent);
		}
		return result;
	}
}
